﻿<!DOCTYPE html >
<html>
<head>
    <link href="images/5.icon" rel="icon" type="image/x-icon" />
    <title>腾飞健康主页</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery.js" type="text/javascript"></script>
    <link rel="stylesheet" href="lib/layui/css/layui.css">
</head>
<body>
    <div class="head">
        <div class="w1300">
            <div class="top c">
                <div class="l">
                    <span>
                        <script>
                            var d = new Date();
                            document.write(d.getHours() + "时:" + d.getMinutes() + "分"); 
                        </script>
                    </span>
                </div>
                <div class="r">
                    <a href="guanyuwomen.html" target="_blank">关于我们</a><a href="baozhuzhongxin.html"
                        target="_blank">帮助中心</a></div>
            </div>
            <div class="center c">
                <div class="logo l">
                    <img src="images/logo.jpg" />
                </div>
                <div class="search l">
                    <input placeholder="请输入套餐名称,体验内容等" />
                    <div class="btn">
                        <img src="images/search.svg" />
                    </div>
                </div>
            </div>
            <div class="nav c">
                <ul>
                    <li class="act"><a href="/index" target="_self">首 页</a></li>
                    <li><a href="/yiyuan" target="_blank">体 验 医 院</a></li>
                    <li><a href="/taocan" target="_blank">体 验 套 餐</a></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="sec1">
        <div class="w1300">
            <div id="list-mainbox">
                <div class="user_fl fl new-user_fl">
                    <h1>
                        订单管理</h1>
                    <div class="user_order">
                        <ul>
                            <li><a href="/userdingdan">未成功订单</a></li>
                            <li><a href="/userdingdanwc">成功订单</a></li>
                            <li><a href="/userdingdanwcg">未完成订单</a></li>
                        </ul>
                    </div>
                    <h1>
                        个人信息</h1>
                    <div class="user_order">
                        <ul>
                            <li><a href="/user">个人资料设置</a></li>
                            <li class="click"><a href="/anquan">安全设置</a></li>
                        </ul>
                    </div>
                    <h1>
                        历史记录</h1>
                    <div class="user_order">
                        <ul>
                            <li><a href="/baogao">体检报告</a></li>
                        </ul>
                    </div>
                </div>
                <div class="user_rt rt new-user_rt" style="padding-top: 50px; padding-bottom: 50px">
                    <form class="layui-form">
                        <div class="layui-form-item ">
                            <label class="layui-form-label">原密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="originalPwd" placeholder="请输入原密码" class="layui-input"
                                       lay-verify="required" autocomplete="off" maxlength="16">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="newPwd" placeholder="请输入新密码" class="layui-input" lay-verify="required"
                                       autocomplete="off" maxlength="16">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="confirmPwd" placeholder="请再次输入新密码" class="layui-input"
                                       lay-verify="required" autocomplete="off" maxlength="16">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="submitPwd">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="foot">
        <p align="center">
            版权所有 腾飞健康</p>
    </div>
    <script src="lib/layui/layui.js" type="text/javascript"></script>
    <script type="text/javascript">
        layui.use(["jquery", "form"], function () {
            let $ = layui.jquery;
            let form = layui.form;


            //提交数据
            form.on("submit(submitPwd)", function (data) {
                //对比‘确认密码’中的数据和‘新密码’中的数据是否一样，如果一样，就提交数据，否则不提交。
                if (data.field.newPwd != data.field.confirmPwd) {
                    layer.msg("确认密码和新密码不一致", {icon: 2, time: 1500});
                    return false;
                } else {
                    let loadIndex;
                    $.ajax({
                        url: "/updateSelfPassword",
                        type: "post",
                        dataType: "json",
                        data: data.field,
                        async: true,
                        beforeSend: function () {
                            loadIndex = layer.load();
                        },
                        success: function (responseResult) {
                            layer.close(loadIndex);
                            if (responseResult.code == 1) {
                                layer.open({
                                    type: 1,
                                    title: "提示",
                                    btn: "确定",
                                    btnAlign: "c", //按钮居中
                                    closeBtn: 0,   //去掉右上角关闭按钮
                                    content: "<div style='padding: 20px 80px;'>" + responseResult.msg + '</div>',
                                    yes: function () {
                                        //点击关闭按钮，回到登录页面
                                        $.ajax({
                                            url: "/logout",
                                            type: "post",
                                            async: true,
                                            success: function (responseResult) {
                                                window.location = "/unitLogin";
                                            }
                                        });
                                    }
                                });
                                console.log(responseResult.msg);
                            } else {
                                layer.msg(responseResult.msg, {icon: 2, time: 1500});
                                console.log(responseResult.msg);
                            }
                        },
                        error: function (XMLhttpRequest, textSatus, errorThrown) {
                            layer.close(loadIndex);
                            layer.msg("服务器错误", {icon: 2, time: 1500});
                            console.log("服务器错误");
                        },
                    });
                }
                return false;
            });

        });
    </script>
</body>
</html>
